#算法复杂度：O(n)时间
def max_subarray_kadane(arr):
    max_current = max_global = arr[0]
    start = end = 0
    temp_start = 0  # 临时记录起始位置

    for i in range(1, len(arr)):
        if arr[i] > max_current + arr[i]:
            max_current = arr[i]
            temp_start = i
        else:
            max_current += arr[i]

        if max_current > max_global:
            max_global = max_current
            start = temp_start
            end = i

    return max_global, (start, end)

arr = [1, -2, 3, 10, -4, 7, 2, -5, -8, 6]
print(max_subarray_kadane(arr))       # 输出: (18, (2, 6))
